import { useEffect } from 'react';
import { useDescriptionsType } from '@/components/DescriptionsType';
import { DatePicker, Form } from 'antd';
import { UploadFormCommon } from '@/components/UploadForm';

const getFinishConfig = ({ record }) => {
  /** 表单数据 */
  const [finishForm] = Form.useForm();

  /** 切换表单 */
  useEffect(() => {}, [record]);

  /** 表单配置 */
  const [config, methods] = useDescriptionsType({
    labelWidth: 190,
    basicForm: finishForm,
    name: 'accept-finish',
    schemas: [
      {
        key: 'accept-basic',
        title: '',
        fieldChildren: [
          {
            field: `handlePerson`,
            label: `维修人`,
            component: 'Input',
            disabled: false,
            placeholder: '请输入',
            required: false,
          },
          {
            field: `handleTime`,
            label: `完成时间`,
            component: 'Render',
            required: false,
            placeholder: '请选择',
            render: (text, record) => {
              return <DatePicker placeholder="请选择" format={'YYYY-MM-DD'} disabled={false} />;
            },
          },
          {
            field: `newMaintenTime`,
            label: `下次维保日期`,
            required: true,
            component: 'Render',
            disabled: false,
            colSpan: 1,
            placeholder: '请选择',
            render: (text, record) => {
              return <DatePicker placeholder="请选择" format={'YYYY-MM-DD'} disabled={false} />;
            },
          },
          {
            field: `handleNumber`,
            label: `维修人电话`,
            component: 'Input',
            // required: true,
            placeholder: '请输入',
            disabled: false,
          },
          {
            field: `spend`,
            label: `维修花费`,
            component: 'InputNumber',
            // required: true,
            placeholder: '请输入',
            min: 0,
            disabled: false,
          },
          {
            field: `handleProve`,
            label: `回执单`,
            component: 'Render',
            disabled: false,
            placeholder: '请选择',
            render: (text, record) => {
              const fileName = 'handleProve';
              return (
                <>
                  <UploadFormCommon
                    form={finishForm}
                    fileFormName={fileName}
                    spanCol={24}
                    inRowProportion={24}
                    name={'attachFile'}
                    required={false}
                    // accept={'.doc|.docx'}
                    url={'/assetInfo/uploadFile'}
                    downloadUrl={'/assetInfo/downloadFile'}
                    fileFormDelName={'delFile'}
                    delFunc={(delFilePath: string) => {
                      console.log('--- w文件url', delFilePath);
                    }}
                    // maxFile={1}
                    defaultFiles={text}
                    // hintTitle={'且只能上传 1 个！'}
                    fieldBusiPath={'assetFile'}
                  >
                    上传
                  </UploadFormCommon>
                </>
              );
            },
          },
        ],
      },
    ],
  });

  return {
    config,
    methods,
  };
};

export { getFinishConfig };
